package com.busi.framework.action;

import java.util.HashMap;
import java.util.Map;

import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.busi.utils.tools.StringTools;

public class ParameterActionForward extends ActionMapping{
	private ActionForward forward = null;
	private Map map = new HashMap();
	public void setParam(String key , String value){
		map.put(key, value);
	}
	
	public ParameterActionForward(ActionForward forward){
		this.forward = forward;
	}
	
	public ActionForward findForwardParam(){
		return replaceParamInPath(forward , map);
	}
	
	
	
	private ActionForward replaceParamInPath(ActionForward forward , Map map){
		String path = StringTools.setParameters(forward.getPath() , map);
		
		ActionForward newForward = new ActionForward();
		newForward.setPath(path);
		newForward.setRedirect(forward.getRedirect());
		return newForward;
	}
}
